import logging
import unittest

from common import *
from Board import *
from RandomAgent import *
from AIAgentMinimax import *
from AIAgentOneLookAhead import *

class CreateAgent(unittest.TestCase):
    def setUp(self):
        pass

    def testAIAgentOneLookAhead(self):
        b = Board(4)
        b.drop(1,1)
        b.drop(1,1)
        b.drop(1,1)
        agent = AIAgentOneLookAhead(1)
        agent.play(b)
        self.assertEqual(1, b.board[1,3])

    def testAIAgentMinimax(self):
        b = Board(4)
        b.drop(1,1)
        b.drop(1,1)
        b.drop(1,1)
        agent = AIAgentMinimax(1, 1)
        agent.play(b)
        self.assertEqual(1, b.board[1,3])

    def testAIAgentMinimax2(self):
        b = Board(4)
        b.drop(1,1)
        b.drop(1,1)
        b.drop(2,2)
        b.drop(2,2)
        b.drop(2,2)
        agent = AIAgentMinimax(1, 1)
        agent.play(b)
        self.assertEqual(1, b.board[2,3])

    def testAIAgentMinimax3(self):
        b = Board(5)
        b.drop(0,1)
        b.drop(0,2)
        b.drop(0,1)
        b.drop(1,2)
        b.drop(1,1)
        b.drop(1,1)
        b.drop(2,2)
        b.drop(2,2)
        b.drop(2,1)
        b.drop(3,1)
        agent = AIAgentMinimax(1, 2)
        agent.play(b)
        self.assertEqual(1, b.board[3,1])
        
#logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)s: %(message)s', datefmt='%H:%M:%S')

if __name__ == "__main__":
    unittest.main()   